﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.DXErrorProvider;
using Dogshow.Model;
using Dogshow.Win.DataAccess;
using Dogshow.Win.Models;
using Dogshow.Win.UserControls;
using Shell;
using System.Linq;
using Shell.Events;
using Pas = Dogshow.Win.Models.Pas;
using RasaPsa = Dogshow.Model.RasaPsa;
using Dogshow.Win.Helpers;

namespace Dogshow.Win.Views
{
    public class PsiView : ViewBase
    {
        private DevExpress.XtraLayout.LayoutControl layoutControl1;
        private DevExpress.XtraGrid.GridControl gridControl1;
        private System.Windows.Forms.BindingSource infoOPsuBindingSource;
        private System.ComponentModel.IContainer components;
        private DevExpress.XtraGrid.Views.Grid.GridView gridView1;
        private DevExpress.XtraGrid.Columns.GridColumn colBrojRodovnika;
        private DevExpress.XtraGrid.Columns.GridColumn colImePsa;
        private DevExpress.XtraGrid.Columns.GridColumn colRasa;
        private DevExpress.XtraGrid.Columns.GridColumn colFciGrupa;
        private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroup1;
        private DevExpress.XtraEditors.DateEdit dateEdit1;
        private DevExpress.XtraEditors.LookUpEdit lookUpEdit1;
        private DevExpress.XtraEditors.TextEdit textEdit2;
        private DevExpress.XtraEditors.TextEdit textEdit1;
        private System.Windows.Forms.BindingSource rasaPsaBindingSource;
        private DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider dxErrorProvider1;
        private DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox repositoryItemImageComboBox1;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1;

        private IDataService m_DataService = new WebDataService();

        private IEnumerable<FciGrupa> m_FciGrupe;
        private System.Windows.Forms.ImageList imageList1;

        private BindingList<InfoOPsu> m_InfoOPsima = new BindingList<InfoOPsu>();
        private System.Windows.Forms.BindingSource pasBindingSource;
        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem2;
        private DevExpress.XtraLayout.LayoutControl layoutControl2;
        private DevExpress.XtraLayout.LayoutControlGroup Root;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem3;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem4;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem5;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem7;
        private UserControls.IzborPsa izborPsa1;
        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem8;
        private UserControls.IzborPsa izborPsa2;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem9;
        private DXErrorProvider dxErrorProvider2;
        private RasaPsa[] m_RasePasa;
        private DevExpress.XtraGrid.GridControl gridControl2;
        private DevExpress.XtraGrid.Views.Grid.GridView gridView2;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem10;
        private BindingSource tituleBindingSource;
        private DevExpress.XtraGrid.Columns.GridColumn colIdTitule;
        private DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit repositoryItemLookUpEdit1;
        private DevExpress.XtraGrid.Columns.GridColumn colBrojTitula;
        private BindingSource titulaBindingSource;
        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem3;
        private IzborKinologa izborKinologa1;
        private IzborKinologa izborKinologa2;
        private IzborKinologa izborKinologa3;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem6;
        private IzborKinologa izborKinologa4;
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem11;

        private Dictionary<int, Pas> m_CachePsi = new Dictionary<int, Pas>();

        public PsiView()
        {
            InitializeComponent();
            dxErrorProvider1.SetIconAlignment(textEdit1, ErrorIconAlignment.MiddleLeft);
            dxErrorProvider2.SetIconAlignment(textEdit1, ErrorIconAlignment.MiddleRight);
            infoOPsuBindingSource.CurrentChanged += (s, e) => UcitajPodatkeOPsu();
            pasBindingSource.CurrentChanged += (s, e) =>
            {
                layoutControl2.Enabled = pasBindingSource.Current != null;
            };
            layoutControl2.Enabled = false;
            
            textEdit1.KeyDown += (s, e) =>
                                   {
                                       if (e.KeyData == Keys.Enter && IzabraniPas != null)
                                       {
                                           var postojiRodovnik = m_DataService.PostojiPas(textEdit1.Text, IzabraniPas.Id);
                                           if (postojiRodovnik)
                                           {
                                               dxErrorProvider2.SetError((Control)s, "Postoji rodovnik sa tim brojem", ErrorType.Warning);
                                           }
                                           else
                                           {
                                               dxErrorProvider2.ClearErrors();
                                           }
                                       }
                                   };
        }

        private void UcitajPodatkeOPsu()
        {
            var info = infoOPsuBindingSource.Current as InfoOPsu;
            if (info == null) pasBindingSource.DataSource = typeof(Pas);
            else
            {
                Pas pas;
                if (m_CachePsi.ContainsKey(info.Id))
                {
                    pas = m_CachePsi[info.Id];
                    pasBindingSource.DataSource = pas;
                }
                else
                {
                    var p = m_DataService.VratiPsaPoId(info.Id);
                    pas = ModelMapper.Map(p);
                    if (pas != null)
                    {
                        m_CachePsi.Add(info.Id, pas);
                        pasBindingSource.DataSource = pas;
                    }
                }
            }
        }

        protected override void OnLoad(System.EventArgs e)
        {
            m_FciGrupe = m_DataService.VratiFciGrupe();
            repositoryItemImageComboBox1.Items.AddRange(m_FciGrupe.Select(x => new ImageComboBoxItem(x.Naziv, x, x.Id -1)).ToArray());
            m_RasePasa = m_DataService.VratiRasePasa().ToArray();
            rasaPsaBindingSource.DataSource = m_RasePasa;
            titulaBindingSource.DataSource = m_DataService.VratiTitule();
            OnRefresh();
        }

        public override void OnNew()
        {
            pasBindingSource.DataSource = new Pas();
            textEdit1.Focus();
            textEdit1.SendKey(new KeyEventArgs(Keys.End));
        }

        public override void OnSave()
        {
            var pas = IzabraniPas;
            if (pas == null) return;
            if (!pas.IsValid)
            {
                OnAlertChanged(new WarningAlertEventArgs(pas.GetErrors()));
                return;
            }
            m_DataService.Sacuvaj(pas);
            OnRefresh();
            OnAlertChanged(new AlertEventArgs("Podaci su uspešno sačuvani"));
        }

        public override void OnSearch()
        {
            using (var dlg = new PretragaPasa())
            {
                var ok = dlg.ShowDialog(this);
                if (ok == DialogResult.OK && dlg.IzabranPas != null)
                {
                    var psi = (BindingList<InfoOPsu>) infoOPsuBindingSource.DataSource;
                    var info = psi.FirstOrDefault(x => x.Id == dlg.IzabranPas.Id);
                    if (info != null) infoOPsuBindingSource.MoveTo(info);
                }
            }
        }

        private Pas IzabraniPas
        {
            get { return pasBindingSource.Current as Pas; }
        }

        public override void OnRefresh()
        {
            m_CachePsi.Clear();
            var info = m_DataService.VratInfoOPsima().ToList();
            m_InfoOPsima = new BindingList<InfoOPsu>(info);
            infoOPsuBindingSource.DataSource = m_InfoOPsima;
        }


        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PsiView));
            this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
            this.layoutControl2 = new DevExpress.XtraLayout.LayoutControl();
            this.izborKinologa4 = new Dogshow.Win.UserControls.IzborKinologa();
            this.pasBindingSource = new System.Windows.Forms.BindingSource();
            this.izborKinologa3 = new Dogshow.Win.UserControls.IzborKinologa();
            this.gridControl2 = new DevExpress.XtraGrid.GridControl();
            this.tituleBindingSource = new System.Windows.Forms.BindingSource();
            this.gridView2 = new DevExpress.XtraGrid.Views.Grid.GridView();
            this.colIdTitule = new DevExpress.XtraGrid.Columns.GridColumn();
            this.repositoryItemLookUpEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit();
            this.titulaBindingSource = new System.Windows.Forms.BindingSource();
            this.colBrojTitula = new DevExpress.XtraGrid.Columns.GridColumn();
            this.izborPsa2 = new Dogshow.Win.UserControls.IzborPsa();
            this.izborPsa1 = new Dogshow.Win.UserControls.IzborPsa();
            this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
            this.textEdit2 = new DevExpress.XtraEditors.TextEdit();
            this.lookUpEdit1 = new DevExpress.XtraEditors.LookUpEdit();
            this.rasaPsaBindingSource = new System.Windows.Forms.BindingSource();
            this.dateEdit1 = new DevExpress.XtraEditors.DateEdit();
            this.Root = new DevExpress.XtraLayout.LayoutControlGroup();
            this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem();
            this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
            this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem();
            this.layoutControlItem5 = new DevExpress.XtraLayout.LayoutControlItem();
            this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
            this.layoutControlItem8 = new DevExpress.XtraLayout.LayoutControlItem();
            this.layoutControlItem9 = new DevExpress.XtraLayout.LayoutControlItem();
            this.layoutControlItem10 = new DevExpress.XtraLayout.LayoutControlItem();
            this.emptySpaceItem3 = new DevExpress.XtraLayout.EmptySpaceItem();
            this.layoutControlItem6 = new DevExpress.XtraLayout.LayoutControlItem();
            this.layoutControlItem11 = new DevExpress.XtraLayout.LayoutControlItem();
            this.gridControl1 = new DevExpress.XtraGrid.GridControl();
            this.infoOPsuBindingSource = new System.Windows.Forms.BindingSource();
            this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
            this.colBrojRodovnika = new DevExpress.XtraGrid.Columns.GridColumn();
            this.colImePsa = new DevExpress.XtraGrid.Columns.GridColumn();
            this.colRasa = new DevExpress.XtraGrid.Columns.GridColumn();
            this.colFciGrupa = new DevExpress.XtraGrid.Columns.GridColumn();
            this.repositoryItemImageComboBox1 = new DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox();
            this.imageList1 = new System.Windows.Forms.ImageList();
            this.layoutControlGroup1 = new DevExpress.XtraLayout.LayoutControlGroup();
            this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
            this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem();
            this.layoutControlItem7 = new DevExpress.XtraLayout.LayoutControlItem();
            this.dxErrorProvider1 = new DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider();
            this.dxErrorProvider2 = new DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
            this.layoutControl1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControl2)).BeginInit();
            this.layoutControl2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pasBindingSource)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridControl2)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tituleBindingSource)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridView2)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemLookUpEdit1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.titulaBindingSource)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.textEdit2.Properties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.lookUpEdit1.Properties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.rasaPsaBindingSource)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dateEdit1.Properties.VistaTimeProperties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dateEdit1.Properties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem9)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem3)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem6)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem11)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.infoOPsuBindingSource)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemImageComboBox1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider2)).BeginInit();
            this.SuspendLayout();
            // 
            // layoutControl1
            // 
            this.layoutControl1.Controls.Add(this.layoutControl2);
            this.layoutControl1.Controls.Add(this.gridControl1);
            this.layoutControl1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.layoutControl1.Location = new System.Drawing.Point(0, 0);
            this.layoutControl1.Name = "layoutControl1";
            this.layoutControl1.OptionsCustomizationForm.DesignTimeCustomizationFormPositionAndSize = new System.Drawing.Rectangle(694, 259, 250, 350);
            this.layoutControl1.Root = this.layoutControlGroup1;
            this.layoutControl1.Size = new System.Drawing.Size(906, 526);
            this.layoutControl1.TabIndex = 0;
            this.layoutControl1.Text = "layoutControl1";
            // 
            // layoutControl2
            // 
            this.layoutControl2.Controls.Add(this.izborKinologa4);
            this.layoutControl2.Controls.Add(this.izborKinologa3);
            this.layoutControl2.Controls.Add(this.gridControl2);
            this.layoutControl2.Controls.Add(this.izborPsa2);
            this.layoutControl2.Controls.Add(this.izborPsa1);
            this.layoutControl2.Controls.Add(this.textEdit1);
            this.layoutControl2.Controls.Add(this.textEdit2);
            this.layoutControl2.Controls.Add(this.lookUpEdit1);
            this.layoutControl2.Controls.Add(this.dateEdit1);
            this.layoutControl2.Location = new System.Drawing.Point(318, 12);
            this.layoutControl2.Name = "layoutControl2";
            this.layoutControl2.OptionsCustomizationForm.DesignTimeCustomizationFormPositionAndSize = new System.Drawing.Rectangle(1139, 226, 250, 350);
            this.layoutControl2.Root = this.Root;
            this.layoutControl2.Size = new System.Drawing.Size(381, 502);
            this.layoutControl2.TabIndex = 10;
            this.layoutControl2.Text = "layoutControl2";
            // 
            // izborKinologa4
            // 
            this.izborKinologa4.ControlSize = new System.Drawing.Size(161, 20);
            this.izborKinologa4.DataBindings.Add(new System.Windows.Forms.Binding("Kinolog", this.pasBindingSource, "Odgajivac", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
            this.izborKinologa4.Kinolog = null;
            this.izborKinologa4.Location = new System.Drawing.Point(89, 132);
            this.izborKinologa4.Margin = new System.Windows.Forms.Padding(0);
            this.izborKinologa4.Name = "izborKinologa4";
            this.izborKinologa4.Size = new System.Drawing.Size(280, 20);
            this.izborKinologa4.TabIndex = 14;
            // 
            // pasBindingSource
            // 
            this.pasBindingSource.DataSource = typeof(Dogshow.Win.Models.Pas);
            // 
            // izborKinologa3
            // 
            this.izborKinologa3.ControlSize = new System.Drawing.Size(161, 20);
            this.izborKinologa3.DataBindings.Add(new System.Windows.Forms.Binding("Kinolog", this.pasBindingSource, "Vlasnik", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
            this.izborKinologa3.Kinolog = null;
            this.izborKinologa3.Location = new System.Drawing.Point(89, 108);
            this.izborKinologa3.Margin = new System.Windows.Forms.Padding(0);
            this.izborKinologa3.Name = "izborKinologa3";
            this.izborKinologa3.Size = new System.Drawing.Size(280, 20);
            this.izborKinologa3.TabIndex = 13;
            // 
            // gridControl2
            // 
            this.gridControl2.DataSource = this.tituleBindingSource;
            this.gridControl2.Location = new System.Drawing.Point(12, 221);
            this.gridControl2.MainView = this.gridView2;
            this.gridControl2.Name = "gridControl2";
            this.gridControl2.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
            this.repositoryItemLookUpEdit1});
            this.gridControl2.Size = new System.Drawing.Size(357, 77);
            this.gridControl2.TabIndex = 12;
            this.gridControl2.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
            this.gridView2});
            // 
            // tituleBindingSource
            // 
            this.tituleBindingSource.DataMember = "Titule";
            this.tituleBindingSource.DataSource = this.pasBindingSource;
            // 
            // gridView2
            // 
            this.gridView2.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
            this.colIdTitule,
            this.colBrojTitula});
            this.gridView2.GridControl = this.gridControl2;
            this.gridView2.Name = "gridView2";
            this.gridView2.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
            this.gridView2.OptionsView.ShowGroupPanel = false;
            // 
            // colIdTitule
            // 
            this.colIdTitule.Caption = "Ocena/Titula";
            this.colIdTitule.ColumnEdit = this.repositoryItemLookUpEdit1;
            this.colIdTitule.FieldName = "IdTitule";
            this.colIdTitule.Name = "colIdTitule";
            this.colIdTitule.Visible = true;
            this.colIdTitule.VisibleIndex = 0;
            this.colIdTitule.Width = 345;
            // 
            // repositoryItemLookUpEdit1
            // 
            this.repositoryItemLookUpEdit1.AutoHeight = false;
            this.repositoryItemLookUpEdit1.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
            this.repositoryItemLookUpEdit1.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] {
            new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Naziv", "Naziv", 36, DevExpress.Utils.FormatType.None, "", true, DevExpress.Utils.HorzAlignment.Near)});
            this.repositoryItemLookUpEdit1.DataSource = this.titulaBindingSource;
            this.repositoryItemLookUpEdit1.DisplayMember = "Naziv";
            this.repositoryItemLookUpEdit1.Name = "repositoryItemLookUpEdit1";
            this.repositoryItemLookUpEdit1.NullText = "[Unesite novu titulu/ocenu]";
            this.repositoryItemLookUpEdit1.ValueMember = "Id";
            // 
            // titulaBindingSource
            // 
            this.titulaBindingSource.DataSource = typeof(Dogshow.Model.Titula);
            // 
            // colBrojTitula
            // 
            this.colBrojTitula.Caption = "Broj";
            this.colBrojTitula.FieldName = "BrojTitula";
            this.colBrojTitula.Name = "colBrojTitula";
            this.colBrojTitula.Visible = true;
            this.colBrojTitula.VisibleIndex = 1;
            this.colBrojTitula.Width = 65;
            // 
            // izborPsa2
            // 
            this.izborPsa2.DataBindings.Add(new System.Windows.Forms.Binding("Pas", this.pasBindingSource, "Majka", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
            this.izborPsa2.Location = new System.Drawing.Point(89, 181);
            this.izborPsa2.Name = "izborPsa2";
            this.izborPsa2.Pas = null;
            this.izborPsa2.Size = new System.Drawing.Size(280, 20);
            this.izborPsa2.TabIndex = 11;
            // 
            // izborPsa1
            // 
            this.izborPsa1.DataBindings.Add(new System.Windows.Forms.Binding("Pas", this.pasBindingSource, "Otac", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
            this.izborPsa1.Location = new System.Drawing.Point(89, 156);
            this.izborPsa1.Name = "izborPsa1";
            this.izborPsa1.Pas = null;
            this.izborPsa1.Size = new System.Drawing.Size(280, 21);
            this.izborPsa1.TabIndex = 10;
            // 
            // textEdit1
            // 
            this.textEdit1.DataBindings.Add(new System.Windows.Forms.Binding("EditValue", this.pasBindingSource, "BrojRodovnika", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
            this.textEdit1.EnterMoveNextControl = true;
            this.textEdit1.Location = new System.Drawing.Point(89, 12);
            this.textEdit1.Name = "textEdit1";
            this.textEdit1.Size = new System.Drawing.Size(161, 20);
            this.textEdit1.StyleController = this.layoutControl2;
            this.textEdit1.TabIndex = 5;
            // 
            // textEdit2
            // 
            this.textEdit2.DataBindings.Add(new System.Windows.Forms.Binding("EditValue", this.pasBindingSource, "ImePsa", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
            this.textEdit2.EnterMoveNextControl = true;
            this.textEdit2.Location = new System.Drawing.Point(89, 36);
            this.textEdit2.Name = "textEdit2";
            this.textEdit2.Size = new System.Drawing.Size(161, 20);
            this.textEdit2.StyleController = this.layoutControl2;
            this.textEdit2.TabIndex = 6;
            // 
            // lookUpEdit1
            // 
            this.lookUpEdit1.DataBindings.Add(new System.Windows.Forms.Binding("EditValue", this.pasBindingSource, "IdRase", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
            this.lookUpEdit1.EnterMoveNextControl = true;
            this.lookUpEdit1.Location = new System.Drawing.Point(89, 60);
            this.lookUpEdit1.Name = "lookUpEdit1";
            this.lookUpEdit1.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.False;
            this.lookUpEdit1.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
            this.lookUpEdit1.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
            this.lookUpEdit1.Properties.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] {
            new DevExpress.XtraEditors.Controls.LookUpColumnInfo("NazivRase", "Naziv Rase", 63, DevExpress.Utils.FormatType.None, "", true, DevExpress.Utils.HorzAlignment.Near),
            new DevExpress.XtraEditors.Controls.LookUpColumnInfo("OriginalniNazivRase", "Originalni Naziv Rase", 110, DevExpress.Utils.FormatType.None, "", true, DevExpress.Utils.HorzAlignment.Near)});
            this.lookUpEdit1.Properties.DataSource = this.rasaPsaBindingSource;
            this.lookUpEdit1.Properties.DisplayMember = "NazivRase";
            this.lookUpEdit1.Properties.DropDownRows = 30;
            this.lookUpEdit1.Properties.NullText = "[Rasa nije izabrana]";
            this.lookUpEdit1.Properties.ShowFooter = false;
            this.lookUpEdit1.Properties.ShowHeader = false;
            this.lookUpEdit1.Properties.ValueMember = "Id";
            this.lookUpEdit1.Size = new System.Drawing.Size(161, 20);
            this.lookUpEdit1.StyleController = this.layoutControl2;
            this.lookUpEdit1.TabIndex = 7;
            // 
            // rasaPsaBindingSource
            // 
            this.rasaPsaBindingSource.DataSource = typeof(Dogshow.Win.Models.RasaPsa);
            // 
            // dateEdit1
            // 
            this.dateEdit1.DataBindings.Add(new System.Windows.Forms.Binding("EditValue", this.pasBindingSource, "Ostenjen", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
            this.dateEdit1.EditValue = null;
            this.dateEdit1.EnterMoveNextControl = true;
            this.dateEdit1.Location = new System.Drawing.Point(89, 84);
            this.dateEdit1.Name = "dateEdit1";
            this.dateEdit1.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
            this.dateEdit1.Properties.VistaTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            new DevExpress.XtraEditors.Controls.EditorButton()});
            this.dateEdit1.Size = new System.Drawing.Size(161, 20);
            this.dateEdit1.StyleController = this.layoutControl2;
            this.dateEdit1.TabIndex = 8;
            // 
            // Root
            // 
            this.Root.CustomizationFormText = "Root";
            this.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
            this.Root.GroupBordersVisible = false;
            this.Root.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
            this.layoutControlItem3,
            this.layoutControlItem2,
            this.layoutControlItem4,
            this.layoutControlItem5,
            this.emptySpaceItem1,
            this.layoutControlItem8,
            this.layoutControlItem9,
            this.layoutControlItem10,
            this.emptySpaceItem3,
            this.layoutControlItem6,
            this.layoutControlItem11});
            this.Root.Location = new System.Drawing.Point(0, 0);
            this.Root.Name = "Root";
            this.Root.Size = new System.Drawing.Size(381, 502);
            this.Root.Text = "Root";
            this.Root.TextVisible = false;
            // 
            // layoutControlItem3
            // 
            this.layoutControlItem3.Control = this.textEdit2;
            this.layoutControlItem3.CustomizationFormText = "Ime psa:";
            this.layoutControlItem3.Location = new System.Drawing.Point(0, 24);
            this.layoutControlItem3.Name = "layoutControlItem3";
            this.layoutControlItem3.Size = new System.Drawing.Size(242, 24);
            this.layoutControlItem3.Text = "Ime psa:";
            this.layoutControlItem3.TextSize = new System.Drawing.Size(73, 13);
            // 
            // layoutControlItem2
            // 
            this.layoutControlItem2.Control = this.textEdit1;
            this.layoutControlItem2.CustomizationFormText = "Broj rodovnika:";
            this.layoutControlItem2.Location = new System.Drawing.Point(0, 0);
            this.layoutControlItem2.MaxSize = new System.Drawing.Size(242, 24);
            this.layoutControlItem2.MinSize = new System.Drawing.Size(242, 24);
            this.layoutControlItem2.Name = "layoutControlItem2";
            this.layoutControlItem2.Size = new System.Drawing.Size(242, 24);
            this.layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
            this.layoutControlItem2.Text = "Broj rodovnika:";
            this.layoutControlItem2.TextSize = new System.Drawing.Size(73, 13);
            // 
            // layoutControlItem4
            // 
            this.layoutControlItem4.Control = this.lookUpEdit1;
            this.layoutControlItem4.CustomizationFormText = "Rasa:";
            this.layoutControlItem4.Location = new System.Drawing.Point(0, 48);
            this.layoutControlItem4.Name = "layoutControlItem4";
            this.layoutControlItem4.Size = new System.Drawing.Size(242, 24);
            this.layoutControlItem4.Text = "Rasa:";
            this.layoutControlItem4.TextSize = new System.Drawing.Size(73, 13);
            // 
            // layoutControlItem5
            // 
            this.layoutControlItem5.Control = this.dateEdit1;
            this.layoutControlItem5.CustomizationFormText = "Oštenjen:";
            this.layoutControlItem5.Location = new System.Drawing.Point(0, 72);
            this.layoutControlItem5.Name = "layoutControlItem5";
            this.layoutControlItem5.Size = new System.Drawing.Size(242, 24);
            this.layoutControlItem5.Text = "Oštenjen:";
            this.layoutControlItem5.TextSize = new System.Drawing.Size(73, 13);
            // 
            // emptySpaceItem1
            // 
            this.emptySpaceItem1.AllowHotTrack = false;
            this.emptySpaceItem1.CustomizationFormText = "emptySpaceItem1";
            this.emptySpaceItem1.Location = new System.Drawing.Point(0, 290);
            this.emptySpaceItem1.Name = "emptySpaceItem1";
            this.emptySpaceItem1.Size = new System.Drawing.Size(361, 192);
            this.emptySpaceItem1.Text = "emptySpaceItem1";
            this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
            // 
            // layoutControlItem8
            // 
            this.layoutControlItem8.Control = this.izborPsa1;
            this.layoutControlItem8.CustomizationFormText = "Otac:";
            this.layoutControlItem8.Location = new System.Drawing.Point(0, 144);
            this.layoutControlItem8.MaxSize = new System.Drawing.Size(0, 25);
            this.layoutControlItem8.MinSize = new System.Drawing.Size(181, 25);
            this.layoutControlItem8.Name = "layoutControlItem8";
            this.layoutControlItem8.Size = new System.Drawing.Size(361, 25);
            this.layoutControlItem8.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
            this.layoutControlItem8.Text = "Otac:";
            this.layoutControlItem8.TextSize = new System.Drawing.Size(73, 13);
            // 
            // layoutControlItem9
            // 
            this.layoutControlItem9.Control = this.izborPsa2;
            this.layoutControlItem9.CustomizationFormText = "Majka:";
            this.layoutControlItem9.Location = new System.Drawing.Point(0, 169);
            this.layoutControlItem9.MaxSize = new System.Drawing.Size(0, 24);
            this.layoutControlItem9.MinSize = new System.Drawing.Size(181, 24);
            this.layoutControlItem9.Name = "layoutControlItem9";
            this.layoutControlItem9.Size = new System.Drawing.Size(361, 24);
            this.layoutControlItem9.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
            this.layoutControlItem9.Text = "Majka:";
            this.layoutControlItem9.TextSize = new System.Drawing.Size(73, 13);
            // 
            // layoutControlItem10
            // 
            this.layoutControlItem10.Control = this.gridControl2;
            this.layoutControlItem10.CustomizationFormText = "Titule:";
            this.layoutControlItem10.Location = new System.Drawing.Point(0, 193);
            this.layoutControlItem10.Name = "layoutControlItem10";
            this.layoutControlItem10.Size = new System.Drawing.Size(361, 97);
            this.layoutControlItem10.Text = "Titule:";
            this.layoutControlItem10.TextLocation = DevExpress.Utils.Locations.Top;
            this.layoutControlItem10.TextSize = new System.Drawing.Size(73, 13);
            // 
            // emptySpaceItem3
            // 
            this.emptySpaceItem3.AllowHotTrack = false;
            this.emptySpaceItem3.CustomizationFormText = "emptySpaceItem3";
            this.emptySpaceItem3.Location = new System.Drawing.Point(242, 0);
            this.emptySpaceItem3.Name = "emptySpaceItem3";
            this.emptySpaceItem3.Size = new System.Drawing.Size(119, 96);
            this.emptySpaceItem3.Text = "emptySpaceItem3";
            this.emptySpaceItem3.TextSize = new System.Drawing.Size(0, 0);
            // 
            // layoutControlItem6
            // 
            this.layoutControlItem6.Control = this.izborKinologa3;
            this.layoutControlItem6.CustomizationFormText = "Vlasnik:";
            this.layoutControlItem6.Location = new System.Drawing.Point(0, 96);
            this.layoutControlItem6.MaxSize = new System.Drawing.Size(0, 24);
            this.layoutControlItem6.MinSize = new System.Drawing.Size(201, 24);
            this.layoutControlItem6.Name = "layoutControlItem6";
            this.layoutControlItem6.Size = new System.Drawing.Size(361, 24);
            this.layoutControlItem6.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
            this.layoutControlItem6.Text = "Vlasnik:";
            this.layoutControlItem6.TextSize = new System.Drawing.Size(73, 13);
            // 
            // layoutControlItem11
            // 
            this.layoutControlItem11.Control = this.izborKinologa4;
            this.layoutControlItem11.CustomizationFormText = "Odgajivač:";
            this.layoutControlItem11.Location = new System.Drawing.Point(0, 120);
            this.layoutControlItem11.MaxSize = new System.Drawing.Size(0, 24);
            this.layoutControlItem11.MinSize = new System.Drawing.Size(181, 24);
            this.layoutControlItem11.Name = "layoutControlItem11";
            this.layoutControlItem11.Size = new System.Drawing.Size(361, 24);
            this.layoutControlItem11.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
            this.layoutControlItem11.Text = "Odgajivač:";
            this.layoutControlItem11.TextSize = new System.Drawing.Size(73, 13);
            // 
            // gridControl1
            // 
            this.gridControl1.DataSource = this.infoOPsuBindingSource;
            this.gridControl1.Location = new System.Drawing.Point(12, 12);
            this.gridControl1.MainView = this.gridView1;
            this.gridControl1.Name = "gridControl1";
            this.gridControl1.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
            this.repositoryItemImageComboBox1});
            this.gridControl1.Size = new System.Drawing.Size(302, 502);
            this.gridControl1.TabIndex = 4;
            this.gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
            this.gridView1});
            // 
            // infoOPsuBindingSource
            // 
            this.infoOPsuBindingSource.DataSource = typeof(Dogshow.Model.InfoOPsu);
            // 
            // gridView1
            // 
            this.gridView1.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
            this.colBrojRodovnika,
            this.colImePsa,
            this.colRasa,
            this.colFciGrupa});
            this.gridView1.GridControl = this.gridControl1;
            this.gridView1.GroupCount = 2;
            this.gridView1.GroupFormat = "[#image]{1}";
            this.gridView1.Images = this.imageList1;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsBehavior.Editable = false;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowFooter = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.gridView1.SortInfo.AddRange(new DevExpress.XtraGrid.Columns.GridColumnSortInfo[] {
            new DevExpress.XtraGrid.Columns.GridColumnSortInfo(this.colFciGrupa, DevExpress.Data.ColumnSortOrder.Ascending),
            new DevExpress.XtraGrid.Columns.GridColumnSortInfo(this.colRasa, DevExpress.Data.ColumnSortOrder.Ascending)});
            // 
            // colBrojRodovnika
            // 
            this.colBrojRodovnika.Caption = "Broj rodovnika";
            this.colBrojRodovnika.FieldName = "BrojRodovnika";
            this.colBrojRodovnika.Name = "colBrojRodovnika";
            this.colBrojRodovnika.Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] {
            new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Count, "BrojRodovnika", "Ukupno: {0:n0}")});
            this.colBrojRodovnika.Visible = true;
            this.colBrojRodovnika.VisibleIndex = 0;
            this.colBrojRodovnika.Width = 87;
            // 
            // colImePsa
            // 
            this.colImePsa.Caption = "Ime psa";
            this.colImePsa.FieldName = "ImePsa";
            this.colImePsa.Name = "colImePsa";
            this.colImePsa.Visible = true;
            this.colImePsa.VisibleIndex = 1;
            this.colImePsa.Width = 198;
            // 
            // colRasa
            // 
            this.colRasa.Caption = "Rasa";
            this.colRasa.FieldName = "Rasa";
            this.colRasa.Name = "colRasa";
            this.colRasa.Visible = true;
            this.colRasa.VisibleIndex = 0;
            // 
            // colFciGrupa
            // 
            this.colFciGrupa.Caption = "FCI grupa";
            this.colFciGrupa.ColumnEdit = this.repositoryItemImageComboBox1;
            this.colFciGrupa.FieldName = "FciGrupa";
            this.colFciGrupa.Name = "colFciGrupa";
            this.colFciGrupa.Visible = true;
            this.colFciGrupa.VisibleIndex = 2;
            // 
            // repositoryItemImageComboBox1
            // 
            this.repositoryItemImageComboBox1.AutoHeight = false;
            this.repositoryItemImageComboBox1.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
            this.repositoryItemImageComboBox1.LargeImages = this.imageList1;
            this.repositoryItemImageComboBox1.Name = "repositoryItemImageComboBox1";
            this.repositoryItemImageComboBox1.SmallImages = this.imageList1;
            // 
            // imageList1
            // 
            this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
            this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
            this.imageList1.Images.SetKeyName(0, "Fci1.jpg");
            this.imageList1.Images.SetKeyName(1, "Fci2.jpg");
            this.imageList1.Images.SetKeyName(2, "Fci3.jpg");
            this.imageList1.Images.SetKeyName(3, "Fci4.jpg");
            this.imageList1.Images.SetKeyName(4, "Fci5.jpg");
            this.imageList1.Images.SetKeyName(5, "Fci6.gif");
            this.imageList1.Images.SetKeyName(6, "Fci7.gif");
            this.imageList1.Images.SetKeyName(7, "Fci8.jpg");
            // 
            // layoutControlGroup1
            // 
            this.layoutControlGroup1.CustomizationFormText = "layoutControlGroup1";
            this.layoutControlGroup1.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
            this.layoutControlGroup1.GroupBordersVisible = false;
            this.layoutControlGroup1.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
            this.layoutControlItem1,
            this.emptySpaceItem2,
            this.layoutControlItem7});
            this.layoutControlGroup1.Location = new System.Drawing.Point(0, 0);
            this.layoutControlGroup1.Name = "Root";
            this.layoutControlGroup1.Size = new System.Drawing.Size(906, 526);
            this.layoutControlGroup1.Text = "Root";
            this.layoutControlGroup1.TextVisible = false;
            // 
            // layoutControlItem1
            // 
            this.layoutControlItem1.Control = this.gridControl1;
            this.layoutControlItem1.CustomizationFormText = "layoutControlItem1";
            this.layoutControlItem1.Location = new System.Drawing.Point(0, 0);
            this.layoutControlItem1.Name = "layoutControlItem1";
            this.layoutControlItem1.Size = new System.Drawing.Size(306, 506);
            this.layoutControlItem1.Text = "layoutControlItem1";
            this.layoutControlItem1.TextSize = new System.Drawing.Size(0, 0);
            this.layoutControlItem1.TextToControlDistance = 0;
            this.layoutControlItem1.TextVisible = false;
            // 
            // emptySpaceItem2
            // 
            this.emptySpaceItem2.AllowHotTrack = false;
            this.emptySpaceItem2.CustomizationFormText = "emptySpaceItem2";
            this.emptySpaceItem2.Location = new System.Drawing.Point(691, 0);
            this.emptySpaceItem2.Name = "emptySpaceItem2";
            this.emptySpaceItem2.Size = new System.Drawing.Size(195, 506);
            this.emptySpaceItem2.Text = "emptySpaceItem2";
            this.emptySpaceItem2.TextSize = new System.Drawing.Size(0, 0);
            // 
            // layoutControlItem7
            // 
            this.layoutControlItem7.Control = this.layoutControl2;
            this.layoutControlItem7.CustomizationFormText = "layoutControlItem7";
            this.layoutControlItem7.Location = new System.Drawing.Point(306, 0);
            this.layoutControlItem7.Name = "layoutControlItem7";
            this.layoutControlItem7.Size = new System.Drawing.Size(385, 506);
            this.layoutControlItem7.Text = "layoutControlItem7";
            this.layoutControlItem7.TextSize = new System.Drawing.Size(0, 0);
            this.layoutControlItem7.TextToControlDistance = 0;
            this.layoutControlItem7.TextVisible = false;
            // 
            // dxErrorProvider1
            // 
            this.dxErrorProvider1.ContainerControl = this;
            this.dxErrorProvider1.DataSource = this.pasBindingSource;
            // 
            // dxErrorProvider2
            // 
            this.dxErrorProvider2.ContainerControl = this;
            // 
            // PsiView
            // 
            this.ClientSize = new System.Drawing.Size(906, 526);
            this.Controls.Add(this.layoutControl1);
            this.Name = "PsiView";
            ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit();
            this.layoutControl1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.layoutControl2)).EndInit();
            this.layoutControl2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pasBindingSource)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridControl2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tituleBindingSource)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridView2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemLookUpEdit1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.titulaBindingSource)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.textEdit2.Properties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.lookUpEdit1.Properties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.rasaPsaBindingSource)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dateEdit1.Properties.VistaTimeProperties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dateEdit1.Properties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Root)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem9)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem3)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem6)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem11)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.infoOPsuBindingSource)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemImageComboBox1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider2)).EndInit();
            this.ResumeLayout(false);

        }
    }
}